<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

    <title>编辑</title>
    <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
    <link rel="stylesheet" href="/static/css/global.css">

    <link href="https://cdn.bootcss.com/twitter-bootstrap/3.4.1/css/bootstrap-theme.min.css" rel="stylesheet">
    <link href="https://cdn.bootcss.com/twitter-bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">

    <script src="https://cdn.bootcss.com/jquery/3.4.1/core.js"></script>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js"></script>

    <script src="https://cdn.bootcss.com/twitter-bootstrap/3.4.1/js/bootstrap.min.js"></script>
    <script src="https://cdn.bootcss.com/twitter-bootstrap/3.4.1/js/npm.js"></script>

    <script src="https://cdn.bootcss.com/socket.io/2.3.0/socket.io.js"></script>
</head>

<body style="margin: 0 1em;">
    {%if art%}
    <form action="/edit" method="POST">
        <div class="form-group">
            <label for="title" class="h4 text-primary">标题：</label>
            <input type="text" class="form-control" name="title" id="title" value="{{art.title}}">
        </div>

        <p class="text-danger text-center h3">
            {% for msg in get_flashed_messages() %}
            {{ msg }} <br>
            {% endfor %}
        </p>

        <div class="form-group">
            <label for="content" class="h4 text-primary">文章：</label>
            <textarea name="content" id="content" cols="30" rows="30" class="form-control">{{art.content}}</textarea>
        </div>

        <div class="form-group">
            <div class="row">
                <div class="col-md-1 col-md-offset-1">
                    <input type="submit" name="edit" id="edit" value="提交修改" class="form-control btn btn-success center-block">
                </div>

                <div class="col-md-1 col-md-offset-1">
                    <a href="/home" class="btn btn-info center-block">返回主页</a>
                </div>

                <div class="col-md-1 col-md-offset-1">
                    <input type="submit" name="delete" id="delete" value="删除文章" class="form-control btn btn-danger center-block">
                </div>
            </div>
        </div>

        <p class="text-danger">
            {% for msg in get_flashed_messages() %}
            {{ msg }} <br>
            {% endfor %}
        </p>
    </form>
    {%endif%}

    {%if not art%}
    <form action="/edit" method="POST">
        <div class="form-group">
            <label for="title" class="h4 text-primary">标题：</label>
            <input type="text" class="form-control" name="title" id="title" placeholder="请输入标题">
        </div>

        <div class="form-group">
            <label for="content" class="h4 text-primary">文章：</label>
            <textarea name="content" id="content" cols="30" rows="30" class="form-control" placeholder="输入文章内容"></textarea>
        </div>

        <div class="form-group">
            <input type="submit" name="create" id="create" value="确认创建" class="btn btn-info">
            <a href="/home" class="btn btn-default">返回主页</a>
        </div>
    </form>
    {%endif%}
</body>

</html>
